﻿using System;
using System.Reflection;
using System.Runtime.Serialization;

namespace Cubicle.Core.DataContracts
{
    [DataContract]
    [Serializable]
    public class FieldData
    {

        [DataMember]
        public string FieldName { get; set; }

        [DataMember]
        public string FieldType { get; set; }

        [DataMember]
        public string DeclaringType { get; set; }

        [DataMember]
        public bool IsPublic { get; set; }

        [DataMember]
        public bool IsPrivate { get; set; }

        [DataMember]
        public bool IsAssembly { get; set; }

        [DataMember]
        public bool IsFamily { get; set; }

        [DataMember]
        public bool IsFamilyAndAssembly { get; set; }

        [DataMember]
        public bool IsFamilyOrAssembly { get; set; }

        public FieldData(FieldInfo f)
        {
            FieldName = f.Name;
            FieldType = f.FieldType.FullName ?? f.FieldType.Name;
            DeclaringType = f.DeclaringType.FullName ?? f.DeclaringType.Name;
            IsPublic= f.IsPublic;
            IsPrivate= f.IsPrivate;
            IsAssembly= f.IsAssembly;
            IsFamily= f.IsFamily;
            IsFamilyAndAssembly= f.IsFamilyAndAssembly;
            IsFamilyOrAssembly = f.IsFamilyOrAssembly;
        }

    }
}